﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HomeCare.Model;

namespace HomeCare.View
{
    public partial class RelMedicamentos : Form
    {
        public RelMedicamentos()
        {
            InitializeComponent();
        }

        private void RelMedicamentos_Load(object sender, EventArgs e)
        {
            MedicamentoDados dados = new MedicamentoDados();
            DataSet ds = dados.RelatorioMedicamentos();
            dgvMedicamentos.AutoGenerateColumns = false;
            dgvMedicamentos.ReadOnly = true;
            //dgvMedicamentos.DataSource = ds.Tables[0];
            lblTotal.Text = ds.Tables[0].Rows.Count.ToString();
            if (ds.Tables[0].Rows.Count > 0)
            {
                int row = ds.Tables[0].Rows.Count - 1;
                for (int r = 0; r <= row; r++)
                {
                    dgvMedicamentos.Rows.Add();
                    dgvMedicamentos.Rows[r].Cells[0].Value = ds.Tables[0].Rows[r].ItemArray[1].ToString();
                    dgvMedicamentos.Rows[r].Cells[1].Value = ds.Tables[0].Rows[r].ItemArray[2].ToString();
                }
            }
        }

        private void btnImprimir_Click(object sender, EventArgs e)
        {
            if (dgvMedicamentos.Rows.Count > 0)
            {
                PrintDGV.Print_DataGridView(dgvMedicamentos, "Lista de Medicamentos. Total de: " + lblTotal.Text);
            }
        }
    }
}
